﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeacherHelp.DAL;

namespace TeacherHelp.BLL
{
    public class RoleManager
    {
        private readonly RoleService _roleService;

        public RoleManager()
        {
            _roleService = new DAL.RoleService();
        }

        public List<Model.Role> GetRoleAllList(bool isShowSuperAdmin = false)
        {
            var sql = _roleService.GetRoleInfoAllSQL();
            try
            {
                Log.Info("获取所有角色");
                var result = DBHelper.GetListModel<Model.Role>(sql).Where(m => isShowSuperAdmin ? isShowSuperAdmin : m.Id != 0).ToList();
                return result;
            }
            catch (Exception ex)
            {
                Log.Error("获取角色时出现异常!",ex);
                return default;
            }
        }

    }
}
